<?php 
namespace app\custom\validate;
use think\Validate;

class Custom extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
      'current_id|账号标识' => 'require|max:6',
      'parent_current_id|上级账号标识'  =>  'require|max:6',
      'username|用户名' => 'require|max:20|unique:custom',
      'password|登陆密码' => 'require|max:32|min:6',
      'mobile|手机号' => 'require|mobile',
      'nickname|昵称' => 'max:50',
      'avatar|头像' => 'max:225',
      'email|电子邮箱' => 'email|max:100',
      'last_login_time|最后登录时间' => 'max:10',
      'login_ip|登录ip' => 'max:15',
      'status|账户状态' => 'number|in:-1,1',
      'money|充值金额' => '^[0-9]+(.[0-9]{1,3})?$',
      'account|用户名' => 'require|max:20',
      'oldpassword|旧密码' => 'require|max:32|min:6'
    ];

     /**
     * 提示消息
     */
    protected $message = [
      'money' => '金额格式错误'
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['username','nickname','password','mobile','email'],
        'edit'  => ['nickname','avatar','mobile','email'],
        'disabled' => ['status'],
        'recharge' => ['money'],
        'deduction' => ['money'],
        'edit_password' => ['password','oldpassword'],
        'login' => ['account','password']
    ];
}